module.exports = {
    showZanTopTips(content = '', options = {}, obj) {
        let zanTopTips = obj.data.zanTopTips || {};
        // 如果已经有一个计时器在了，就清理掉先
        if (zanTopTips.timer) {
            clearTimeout(zanTopTips.timer);
            zanTopTips.timer = undefined;
        }

        if (typeof options === 'number') {
            options = {
                duration: options
            };
        }

        // options参数默认参数扩展
        options = Object.assign({
            duration: 3000
        }, options);

        // 设置定时器，定时关闭topTips
        let timer = setTimeout(() => {
            obj.setData({
                'zanTopTips.show': false,
                'zanTopTips.timer': undefined
            });
        }, options.duration);

        // 展示出topTips
        obj.setData({
            zanTopTips: {
                show: true,
                content,
                options,
                timer
            }
        });
    }
};
// {
//   amount: "222"
//   boxNum: "2"
//   cargoDesc: "2"
//   currency: "RMB"
//   departureAddress: "1"
//   departureDate: 1519689600000
//   destinationAddress: "FBA"
//   destinationCountry: "2"
//   destinationType: "1"
//   insuredId: 10
//   insuredId_name: "122联系人"
//   productId: 1
//   productServiceId: 1
//   productServiceRatioId: 1
//   balance: "2"
//   token: "34025fa6-784a-48a5-a550-db00ea4c4b64"
// }